package com.hwadee.controller;

import com.hwadee.pojo.Oldinfo;
import com.hwadee.service.OldinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;
import java.util.List;

@RestController
@RequestMapping("/api/hd")
@CrossOrigin(origins = "*")
public class OldinfoController {

    @Autowired
    private OldinfoService oldinfoService;

    @GetMapping("/test")
    public String test() {
        return "hello";
    }

    @GetMapping("/getlistoldinfo")
    public List<Oldinfo> getlistOldinfo() {
        return oldinfoService.getlistOldinfo();
    }

    @PostMapping("/addoldinfo")
    public String addOldinfo(@RequestBody Oldinfo oldinfo) {
        oldinfoService.addOldInfoWithDoctorId(oldinfo);
        return "添加成功";
    }

    @DeleteMapping("/deloldinfo/{id}")
    public void delOldinfo(@PathVariable String id) {
        oldinfoService.delOldinfo(id);
    }

    @PostMapping("/updateoldinfo")
    public void updateOldinfo(@RequestBody Oldinfo oldinfo) {
        oldinfoService.updateOldinfo(oldinfo);
    }
}
